#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#include "libsapi_common.h"
#include "libsapi_video.h"

int main()
{
	struct vctrl_params params;
	unsigned char *p=NULL;
	unsigned char *temp=NULL;
	int cmd=0;

	memset((char*)&params, 0x00, sizeof(struct vctrl_params));

	while(1){
		printf("please select a cmd: \n");scanf("%d", &cmd);
		switch(cmd){
		case 0:
			printf("please input exposure value: ");scanf("%d", &params.vparams.exposure);
			params.intf = VIDIF_CAMERA(VIDIF_CHIP_NOIP1SN, 0);
			params.cmd  = APIVCMD_SET_EXPOSURE;
			printf("intf=%08x\n", params.intf);
			printf("cmd =%08x\n", params.cmd);
			printf("expo=%08x\n", params.vparams.exposure);
			break;	

		case 1:
			printf("please input cap value: ");scanf("%d", &params.vparams.exposure);
			params.intf = VIDIF_CAMERA(VIDIF_CHIP_NOIP1SN, 0);
			params.cmd  = APIVCMD_CAP_VIDEO;
			printf("intf=%08x\n", params.intf);
			printf("cmd =%08x\n", params.cmd);
			printf("expo=%08x\n", params.vparams.exposure);
			break;	

		case 2:
			printf("please input cap value: ");scanf("%d", &params.vparams.exposure);
			params.intf = VIDIF_CAMERA(VIDIF_CHIP_NOIP1SN, 0);
			params.cmd  = APIVCMD_SET_WHITEBALANCE;
			printf("intf=%08x\n", params.intf);
			printf("cmd =%08x\n", params.cmd);
			printf("expo=%08x\n", params.vparams.exposure);
			break;	

		case 3:
			printf("please input cap value: ");scanf("%d", &params.vparams.exposure);
			params.intf = VIDIF_CAMERA(VIDIF_CHIP_NOIP1SN, 0);
			params.cmd  = APIVCMD_GET_WHITEBALANCE;
			printf("intf=%08x\n", params.intf);
			printf("cmd =%08x\n", params.cmd);
			printf("expo=%08x\n", params.vparams.exposure);
			break;	






		default:
			return 0;
		}

		printf("print p and temp, params size is %d\n", sizeof(struct vctrl_params));
		p = (unsigned char*)(&params);
		printf("p=%x \n", *p);
		temp = p + sizeof(struct vctrl_params) - 1;
		printf("temp=%x \n\n", *temp);
		while(temp!=p){
			printf("%02x", *(unsigned char*)temp);
			temp--;
		}
		printf("\n");
	}



	return 0;
}

